#include<stdio.h>
#include<math.h>

int main()
{
    int n;
    scanf("%d", &n);
    char name[n][10];
    int ret[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d", name[i], &ret[i]);
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += ret[i];
    }
    double k = sum * 1.0 / (n * 2);
    int index = 0;
    for (int i = 1; i < n; i++)
    {
        if (fabs(ret[i] - k) < fabs(ret[index] - k))
        {
            index = i;
        }
    }
    printf("%d %s\n", sum / (n * 2), name[index]);
    return 0;
}